package com.wq.httpclientcore.entities.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.time.LocalDateTime;

@Getter
@Setter
@Accessors(chain = true)
@Schema(name = "DbConnectionConfigVO", description = "数据库连接配置视图对象信息")
public class DbConnectionConfigVO implements Serializable {
    @JsonSerialize(using = ToStringSerializer.class)
    @Schema(description = "数据库连接配置的唯一标识", example = "1")
    private Long id;
    @Schema(description = "数据库连接配置的名称", example = "MySQL 数据库连接")
    private String name;
    @Schema(description = "数据库类型", example = "MySQL")
    private String dbType;
    @Schema(description = "数据库主机地址", example = "localhost")
    private String host;
    @Schema(description = "数据库端口号", example = "3306")
    private Integer port;
    @Schema(description = "数据库名称", example = "test_db")
    private String dbName;
    @Schema(description = "数据库用户名", example = "root")
    private String username;
    @Schema(description = "数据库密码", example = "password")
    private String password;
    @Schema(description = "数据库模式名称", example = "public")
    private String schemaName;
    @Schema(description = "数据库连接配置是否启用", example = "true")
    private Boolean enabled;
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8", shape = JsonFormat.Shape.STRING)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @Schema(description = "数据库连接配置的创建时间", example = "2025-03-12 14:31:39")
    private LocalDateTime createdAt;
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8", shape = JsonFormat.Shape.STRING)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @Schema(description = "数据库连接配置的更新时间", example = "2025-03-12 14:31:39")
    private LocalDateTime updatedAt;
}